From a222af2ef1f49e5c232466ab162fd606732a9d05 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Fri, 23 Nov 2007 16:23:03 +0000 Subject: [PATCH] [Mini-OS] Optimize get_current() Let gcc perform the computation with SP itself, leading to yet better code. Signed-off-by: Samuel Thibault --- extras/mini-os/include/x86/arch_sched.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/extras/mini-os/include/x86/arch_sched.h b/extras/mini-os/include/x86/arch_sched.h index 6bc47f89d3..7bf0036fac 100644 --- a/extras/mini-os/include/x86/arch_sched.h +++ b/extras/mini-os/include/x86/arch_sched.h @@ -7,10 +7,11 @@ static inline struct thread* get_current(void) { struct thread **current; #ifdef __i386__ - __asm__("andl %%esp,%0; ":"=r" (current) : "0" (~8191UL)); + register unsigned long sp asm("esp"); #else - __asm__("andq %%rsp,%0; ":"=r" (current) : "0" (~8191UL)); + register unsigned long sp asm("rsp"); #endif + current = (void *)(sp & ~8191UL); return *current; } -- 2.30.2